const express = require('express');
const router = express.Router();

const examine = require('../../controller/examine')
const error = require('../../middleware/err-handle')

//校验中间键
const taskValidata = require('../../validator/task')
const examineValidata = require('../../validator/examine')

const auth = require('../../middleware/webAuth')

const journal = require('../../controller/journal')

// 提交的审核任务列表
router.get('/submitForReview', auth(), examine.submitForReview)

// 审核别人的任务列表
router.get('/auditOthers', auth(), examine.auditOthers)

// 获取审核列表
router.get('/taskAudit/:userId', auth(), examine.auditList)

// 获取一条审核数据
router.get('/taskAuditOne/:auditId', auth(), examine.auditOne)

// 通过审核
router.put('/adoptAudit/:fileId', auth(), examineValidata.adoptAudit, examine.adoptAudit)

// 任务打回
router.put('/returnAudit/:fileId', auth(), examineValidata.adoptAudit, examine.returnAudit, journal.journalCreate)

// 获取未读审核数量
router.get('/unread/:userId', auth(), examine.getUnread)

// 已读
router.put('/read/:auditId', auth(), examine.handleRead)

router.use(error())

module.exports = router